package cn.hyh.core.vo;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @auther :hyh
 * @desc :
 * @date :2019/7/14
 */
public class ResultVo {
    private static int success = 0;    //成功！
    private static  int error=-1;      //失败！

    private static int errorToUser = -2;  //可以告诉用户的错误



    public  static Map<String,Object>  successResult(Object  data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", success);
        res.put("msg", "请求成功!");
        res.put("result", data);
        return     res;
    }

    public  static Map<String,Object>  errorToUser(Object  data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", errorToUser);
        res.put("msg", "请求失败!");
        res.put("result", data);
        return    res;
    }



    public  static Map<String,Object>  successResultMsg(String msg,Object  data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", success);
        res.put("msg",msg);
        res.put("result", data);
        return     res;
    }


    public  static Map<String,Object>  failRes(Object  data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", error);
        res.put("msg", "请求失败!");
        res.put("result", data);
        return     res;
    }

    public  static Map<String,Object>  failResultMsg(String  errorMsg) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", error);
        res.put("msg", errorMsg);
        res.put("result", null);
        return     res;
    }

    public  static Map<String,Object>  failResultMsgRes(String  errorMsg,Object data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", error);
        res.put("msg", errorMsg);
        res.put("result", data);
        return     res;
    }
}
